package org.hhchat.others.erp;


import java.util.Arrays;
import java.util.Scanner;

public class Main1 {

    public static void main(String[] args){
        //输入
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        System.out.println(solve(n, k));
    }

    public static int solve(int n, int k) {
        int a[] = new int[n];
        //生成数据
        for(int i=1;i<=n;i++) {
            a[i-1]=i;
        }
        //全排列
        arrange(a,0,n,k);
        return total;
    }

    private static int total = 0;
    private static void swap(int[] str, int i, int j)
    {
        int temp = str[i];
        str[i] = str[j];
        str[j] = temp;
    }
    private static void arrange(int[] str, int st, int len,int target)
    {
        //生成排列
        if (st == len - 1)
        {
//            for (int i = 0; i < len; i ++)
//            {
//                System.out.print(str[i]+ "  ");
//            }
//            System.out.println();
            int []temp= Arrays.copyOf(str,str.length);
            if (checkInversion(temp, target)==0) {
                total++;
//                System.out.println("get one");
            }
        }
        else
        {
            for (int i = st; i < len; i++)
            {
                int []temp= Arrays.copyOf(str,str.length);
                if((str[st]<=str[i] && checkInversion(temp, target)<=0)||(str[st]>=str[i] && checkInversion(temp, target)>=0)){
                    swap(str, st, i);
                    arrange(str, st + 1, len,target);
                    swap(str, st, i);
                }else{
//                    System.out.println("skip");
                }
            }
        }
    }

    static int ans;
    static void merge(int[] str, int l, int m, int r)
    {
        int []temp= Arrays.copyOf(str,str.length);
        int i = l;
        int j = m + 1;
        int k = l;
        while(i <= m && j <= r)
        {
            if(str[i] > str[j])
            {
                temp[k++] = str[j++];
                ans += m - i + 1;
            }
            else
            {
                temp[k++] = str[i++];
            }
        }
        while(i <= m) temp[k++] = str[i++];
        while(j <= r) temp[k++] = str[j++];
        for(int index=l;index<=r;index++)
            str[index] = temp[index];
    }

    public static int getInversion(int str[],int l, int h){
        if(l<h){
            int mid = (l+h)/2;
            getInversion(str,mid+1,h);
            getInversion(str,l,mid);
            merge(str,l,mid,h);
        }
        return ans;
    }

    public static int checkInversion(int[] str,int target) {
        ans=0;
        int n = str.length;
        int count = getInversion(str, 0, n-1);
        if(count == target){
            return 0;
        }
        else{
            return -1;
        }
    }
}